<?php
declare(strict_types=1);
namespace Field;

class OneAdzoneConst
{
    public const pk='';
    public const index=['bizCode','campaignId','adgroupId','adzoneId'];
	public const fields=['bizCode','campaignId','adgroupId','adzoneId','adzoneName','bidType','discount','status','faultName','adRotation'];
	public const comment=['bizCode'=>'投放模型','campaignId'=>'计划ID','adgroupId'=>'主体ID','adzoneId'=>'资源位ID','adzoneName'=>'资源位','bidType'=>'','discount'=>'溢价','status'=>'状态','faultName'=>'','adRotation'=>''];
	/*
    * @Field bizCode
    * @Type int(10)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 投放模型
    */
    public const bizCode = 'bizCode';
    /*
    * @Field campaignId
    * @Type bigint(20)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 计划ID
    */
    public const campaignId = 'campaignId';
    /*
    * @Field adgroupId
    * @Type bigint(20)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 主体ID
    */
    public const adgroupId = 'adgroupId';
    /*
    * @Field adzoneId
    * @Type bigint(20)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 资源位ID
    */
    public const adzoneId = 'adzoneId';
    /*
    * @Field adzoneName
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 资源位
    */
    public const adzoneName = 'adzoneName';
    /*
    * @Field bidType
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const bidType = 'bidType';
    /*
    * @Field discount
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 溢价
    */
    public const discount = 'discount';
    /*
    * @Field status
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 状态
    */
    public const status = 'status';
    /*
    * @Field faultName
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const faultName = 'faultName';
    /*
    * @Field adRotation
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const adRotation = 'adRotation';
}

class OneAdzoneColumns
{
public  int $bizCode;
   public  int $campaignId;
   public  int $adgroupId;
   public  int $adzoneId;
   public  ?string $adzoneName='';
   public  ?string $bidType='';
   public  int $discount=0;
   public  ?string $status='';
   public  ?string $faultName='';
   public  ?string $adRotation='';
	public function toArray():array
	{
		return [
'bizCode'=>$this->bizCode,
    'campaignId'=>$this->campaignId,
    'adgroupId'=>$this->adgroupId,
    'adzoneId'=>$this->adzoneId,
    'adzoneName'=>$this->adzoneName,
    'bidType'=>$this->bidType,
    'discount'=>$this->discount,
    'status'=>$this->status,
    'faultName'=>$this->faultName,
    'adRotation'=>$this->adRotation,        ];
	}
}

class OneAdzoneRow
{
	public OneAdzoneColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'bizCode' => $this->data->bizCode,
        'campaignId' => $this->data->campaignId,
        'adgroupId' => $this->data->adgroupId,
        'adzoneId' => $this->data->adzoneId,
        'adzoneName' => $this->data->adzoneName,
        'bidType' => $this->data->bidType,
        'discount' => $this->data->discount,
        'status' => $this->data->status,
        'faultName' => $this->data->faultName,
        'adRotation' => $this->data->adRotation, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new OneAdzoneColumns();
        isset($data['bizCode']) && $this->data->bizCode = (int)$data['bizCode'];
           isset($data['campaignId']) && $this->data->campaignId = (int)$data['campaignId'];
           isset($data['adgroupId']) && $this->data->adgroupId = (int)$data['adgroupId'];
           isset($data['adzoneId']) && $this->data->adzoneId = (int)$data['adzoneId'];
           isset($data['adzoneName']) && $this->data->adzoneName = (string)$data['adzoneName'];
           isset($data['bidType']) && $this->data->bidType = (string)$data['bidType'];
           isset($data['discount']) && $this->data->discount = (int)$data['discount'];
           isset($data['status']) && $this->data->status = (string)$data['status'];
           isset($data['faultName']) && $this->data->faultName = (string)$data['faultName'];
           isset($data['adRotation']) && $this->data->adRotation = (string)$data['adRotation'];
    }
}
?>